import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('你好Flutter')),
        body: Column(
          children: [
            MyApp(),
            SizedBox(height: 20),
            Circular(),
            SizedBox(height: 20),
            ClipImage(),
          ],
        ),
      ),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Container(
          height: 300,
          width: 300,
          color: Colors.yellow,
          child: Image.asset(
            "images/a.jpeg",
            scale: 2, // 缩放
            alignment: Alignment.centerLeft,
            fit: BoxFit.cover, // 充满
          ),
        ),
      ],
    );
  }
}

class Circular extends StatelessWidget {
  const Circular({super.key});

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        height: 150,
        width: 150,
        decoration: const BoxDecoration(
          color: Colors.yellow,
          shape: BoxShape.circle, // 圆形
          image: DecorationImage(
            image: AssetImage("images/a.jpeg"),
            fit: BoxFit.cover,
          ),
        ),
      ),
    );
  }
}

class ClipImage extends StatelessWidget {
  const ClipImage({super.key});

  @override
  Widget build(BuildContext context) {
    return ClipOval(
      child: Image.asset(
        "images/a.jpeg",
        height: 150,
        width: 150,
        fit: BoxFit.cover,
      ),
    );
  }
}
